package cn.emall.item.pojo;

import cn.emall.pojo.TbItem;

/**
 * 扩展TbItem类
 * 主要扩展getImages()方法
 */
public class Item extends TbItem{

    public Item(TbItem tbItem){
        this.setId(tbItem.getId());
        this.setTitle(tbItem.getTitle());
        this.setSellPoint(tbItem.getSellPoint());
        this.setPrice(tbItem.getPrice());
        this.setNum(tbItem.getNum());
        this.setBarcode(tbItem.getBarcode());
        this.setImage(tbItem.getImage());
        this.setCid(tbItem.getCid());
        this.setStatus(tbItem.getStatus());
        this.setCreated(tbItem.getCreated());
        this.setUpdated(tbItem.getUpdated());
    }

    /**
     * 一个商品有几张图片
     * 扩展getImages()方法,页面会调用item.images[0](相当于调用了getImages()方法)
     * 来获得商品图片中的第一张图片显示在搜索页
     * @return 去掉逗号的商品图片地址的数组字符串
     */
    public String[] getImages(){
        String imges2 = this.getImage();
        if(imges2 !=null && !"".equals(imges2)){
            String[] strings = imges2.split(",");
            return strings;
        }
        return null;
    }
}
